# coding: utf-8
"""
@python version : python3.10
@file name      : throttle.py
@date           : 2024/5/6 11:06
@author         : ziyang.yang@aliyun.com
@gitee          : https://gitee.com/ziyangyang1318
@blog           : www.yangziyang.top
@describe       : 
"""
from rest_framework.throttling import SimpleRateThrottle


class MyThrottle(SimpleRateThrottle):
    scope = 'ip_throttle'  # 一个标识符

    def get_cache_key(self, request, view):
        # 返回谁，谁就做限制
        # 针对ip做限制
        return request.META.get('REMOTE_ADDR', None)
